<?php
require_once "E:/php_project/php_demo/tushare/common/http.php";
require_once "E:/php_project/php_demo/tushare/common/mysql.php";
set_time_limit(0);
$conn = new MysqlCommon();
$stockRes = $conn->select("SELECT * FROM tushare.stock_basic");

foreach ($stockRes as $stockResItem){
    $ts_code = $stockResItem["ts_code"];
//    $dailyData = $conn->select("SELECT MAX(close) as max_close FROM tushare.daily WHERE ts_code = '{$ts_code}' ORDER BY trade_date DESC limit 0,10");
//    $max_close = $dailyData[0]["max_close"];
//
//    $dailyData = $conn->select("SELECT close as last_close FROM tushare.daily WHERE ts_code = '{$ts_code}' and trade_date = '20220728' limit 0,1");
//    $last_close = $dailyData[0]["last_close"];
//
//    $dailyData = $conn->select("SELECT close as frist_close FROM tushare.daily WHERE ts_code = '{$ts_code}' and trade_date = '20220708'  limit 0,1");
//    $frist_close = $dailyData[0]["frist_close"];
//
    $dailyData = $conn->select("SELECT * FROM tushare.daily WHERE ts_code = '{$ts_code}' limit 0,20");
    if(count($dailyData) < 20){
        continue;
    }
    if($dailyData[0]["pct_chg"] < 0){
        continue;
    }
    if($dailyData[1]["pct_chg"] > 0){
        continue;
    }
    if($dailyData[2]["pct_chg"] > 0){
        continue;
    }
    if($dailyData[3]["pct_chg"] > 0){
        continue;
    }
    if($dailyData[4]["pct_chg"] > 0){
        continue;
    }
    if($dailyData[5]["pct_chg"] > 0){
        continue;
    }
    if($dailyData[10]["close"] > $dailyData[0]["close"]){
        continue;
    }
    echo $ts_code.PHP_EOL;




}
exit(0);
